package com.twu.biblioteca.Models;

import com.twu.biblioteca.Exceptions.InvalidLoginException;
import com.twu.biblioteca.Exceptions.PasswordCantBeNullException;

/**
 * User: haruo
 * Date: 5/30/13
 */
public class User {
    private final String LOGIN_PATTERN = "((\\d{3})(-\\d{4}))";
    private String login;
    private String password;
    private String name;
    private String email;
    private String phoneNumber;

    public User(String login, String password, String name, String email, String phoneNumber) throws InvalidLoginException, PasswordCantBeNullException {
        if (login == null || !login.matches(LOGIN_PATTERN)) { throw new InvalidLoginException(); }
        if (password == null) { throw new PasswordCantBeNullException(); }
        this.login = login;
        this.password = password;
        this.name = name;
        this.email = email;
        this.phoneNumber = phoneNumber;
    }

    public boolean login(String login, String pass) {
        if (this.login.equals(login) && this.password.equals(pass)) {
            return true;
        }
        return false;
    }

    public String getLogin() {
        return login;
    }

    public String getPassword() {
        return password;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public String getName() {
        return name;
    }

    public String getEmail() {
        return email;
    }

}
